<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCollectionCategoryTable extends Migration
{
    /**
     * 作者 柯良志
     * 选项表
     * 添加时间 2016-8-22
     */
    public function up()
    {
        /** 工作地区集合表 coll_province  **/
        Schema::create('coll_area', function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->mediumInteger('cid')->unsigned()->unique('cid')->default(0)->comment('当前ID');
            $table->string('name', 60)->default('')->comment('地区名称');
            $table->string('en_name', 60)->default('')->comment('英文地区名称');
            $table->tinyInteger('grade')->unsigned()->default(0)->comment('地区级别');
            $table->mediumInteger('pid')->unsigned()->index('pid')->default(0)->comment('父级ID');
            $table->mediumInteger('sort')->unsigned()->index('sort')->default(0)->comment('地区排序');
        });

        /** 工作岗位集合表 coll_position  **/
        Schema::create('coll_position', function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->mediumInteger('cid')->unsigned()->unique('cid')->default(0)->comment('当前ID');
            $table->string('name', 60)->default('')->comment('职位名称');
            $table->string('en_name', 60)->default('')->comment('英文职位名称');
            $table->tinyInteger('grade')->unsigned()->default(0)->comment('职位级别');
            $table->mediumInteger('pid')->unsigned()->index('pid')->default(0)->comment('父级ID');
            $table->mediumInteger('sort')->unsigned()->index('sort')->default(0)->comment('地区排序');
        });

        /** 分类集合表 coll_category **/
        Schema::create('coll_category', function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->string('cate_name', 60)->default('')->comment('分类名称');
            $table->string('sign', 60)->unique()->default('')->comment('分类标识');
        });

        /** 分类选项表 coll_options **/
        Schema::create('coll_options', function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->mediumInteger('opt_sort')->unsigned()->index('opt_sort')->default(0)->comment('分类排序');
            $table->string('opt_name', 60)->default('')->comment('分类名称');
            $table->string('en_opt_name', 60)->default('')->comment('英文分类名称');
            $table->mediumInteger('opt_id')->unsigned()->index('opt_id')->default(0)->comment('分类编码');
            $table->string('sign', 60)->default('')->comment('分类标识');
            $table->unique(['opt_id', 'sign']);
        });

        /** 二级分类选项表 coll_two_options  **/
        Schema::create('coll_two_options', function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->mediumInteger('cid')->unsigned()->index('cid')->default(0)->comment('当前分类ID');
            $table->string('name', 60)->default('')->comment('二级分类职位名称');
            $table->string('en_name', 60)->default('')->comment('英文二级分类职位名称');
            $table->mediumInteger('pid')->default(0)->comment('父级ID');
            $table->mediumInteger('sort')->unsigned()->index('sort')->default(0)->comment('分类排序');
            $table->string('sign', 60)->default('')->comment('分类标识');
            $table->unique(['cid', 'pid']);
        });
    }

    /**
     * 作者 柯良志
     * 选项表
     * 添加时间 2016-8-22
     */
    public function down()
    {
        Schema::dropIfExists('coll_area');
        Schema::dropIfExists('coll_position');
        Schema::dropIfExists('coll_category');
        Schema::dropIfExists('coll_options');
        Schema::dropIfExists('coll_two_options');
    }
}
